﻿@model List<Forum>
@{

    var _topics = ForumContext.GetMvcText(LanguageSection.FORUM, "TOPICS");
    var _posts = ForumContext.GetMvcText(LanguageSection.FORUM, "POSTS");


    foreach (var f in Model)
    {

        var _subforums = ViewBag.ForumId == 0 ? ForumRepo.InHomePage(f.ForumId) : ForumRepo.Sub(f.ForumId);


        if (_subforums!=null && _subforums.Count > 0)
        {
            var _id = string.Format("collapse_forum_{0}", f.ForumId);

            
    <div class="site-block white-t">
        <div class="header">
            <span class="collapse close" id="@_id"></span><span class="icon"></span>
            <h1>
                @Html.Link(ForumContext.ForumLink(f.ForumId, f.ForumName), f.ForumName)
            </h1>
        </div>
        <ul class="list-view" id="@string.Format("panel_{0}", _id)">
            <li class="caption"><span class="fl cell forum-info"><span class="block">
                @ForumContext.GetText(LanguageSection.FORUM, "FORUM")
            </span></span><span class="fl cell forum-lastpost"><span class="block">
                @ForumContext.GetText(LanguageSection.FORUM, "LAST_POST")
            </span></span><span class="fl cell forum-stats"><span class="block">
                @_topics / @_posts
            </span></span>
                <br class="empty" />
            </li>
            @foreach (var s in _subforums)
            {
                <li>
                    <div class="row">
                        <div class="fl cell forum-info">
                            <div class="block">
                                @ForumContext.IconRender(s)
                                <h3>
                                    @Html.Link(!string.IsNullOrWhiteSpace(s.RemoteUrl) ? s.RemoteUrl : ForumContext.ForumLink(s.ForumId, s.ForumName, null), s.ForumName, new { @class = "subject" })
                                </h3>
                                @if (!string.IsNullOrWhiteSpace(s.Description))
                                {
                                    @Html.Raw(String.Format("<span class=\"description\">{0}</span>", s.Description))
                                }
                                @Html.Partial("_SubForum", ForumRepo.Sub(s.ForumId))
                            </div>
                        </div>
                        <div class="fl cell forum-lastpost">
                            <div class="block">
                                @if (ForumContext.ForumAllowRoles(f.AllowRoles))
                                {
                                    if (s.LastPostId > 0)
                                    {

                                    @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_POST, s.LastPostId), s.LastPostTitle.Truncate().Replace("[RE:]", ForumContext.GetText(LanguageSection.TOPICS, "RE")), new { @class = "subject" })
                                    <br />
                                    @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_POST, s.LastPostId), ForumContext.PrettyDate(s.LastPostDate), new { @class = "last-post" })<br />

                                    @Html.Raw(string.Format(ForumContext.GetText(LanguageSection.TOPICS, "POSTER"), s.LastUserPost, ForumContext.GetAbsoluteUrl(ForumUrls.USER_INFO, s.LastUserPost)))

                                    }
                                    else
                                    {

                                    @ForumContext.GetText(LanguageSection.FORUM, "LAST_POST_EMPTY")
                                    }
                                }
                                else
                                {
                                    @ForumContext.GetMvcText(LanguageSection.FORUM, "PRIVATE_ACCESS")
                                }
                            </div>
                        </div>
                        <div class="fl cell forum-stats">
                            <div class="block">
                                @_topics : <strong>@s.TotalTopics</strong><br />
                                @_posts : <strong>@s.TotalReplies</strong>
                            </div>
                        </div>
                        <br class="empty" />
                    </div>
                </li>
            }
        </ul>
    </div>
             
           

        }

    }
}
